import Mock from 'mockjs'
import { CONSTANT_OBJ } from '@/utils/constant'
let baseURL
let locationHref = `http://${window.location.hostname}`
if (CONSTANT_OBJ.ENV !== 'prodMaster') {
  baseURL = CONSTANT_OBJ.URL + CONSTANT_OBJ.PREFIX + '/esale-user'
  // baseURL = URL
} else {
  baseURL = locationHref + CONSTANT_OBJ.PREFIX + '/esale-user'
}
// 用户列表查询
Mock.mock(`${baseURL}/v1/api/esale-user/user/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 2,
      list: [
        { realName: '快乐星球', userId: '78956', gender: 'M', organizationName: '某某分行', roleName: '某莫职务', userStatus: '1', onlineStatus: '2', labelId: '1', labelName: '风险客经', latestLoginTime: '2022-08-01 10:22:12' },
        { realName: '快乐朋友', userId: '78946', gender: 'F', organizationName: '某某分行', roleName: '某莫职务', userStatus: '2', onlineStatus: '1', labelId: '2', labelName: '优质客经', latestLoginTime: '2022-08-01 10:22:12' }
      ]
    }
  }
})

// 添加用户
Mock.mock(`${baseURL}/v1/api/esale-user/user/add`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 标签列表查询
Mock.mock(`${baseURL}/v1/api/esale-user/label/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 3,
      list: [
        { labelName: '风险客经', labelDesc: '用于标记存在展业风险的客户经理', labelId: 1, revision: 1, userList: [{ labelId: 1, realName: '快乐星球', userId: '78956', userName: 'kuailexingqiu' }] },
        { labelName: '优质客经', labelDesc: '用于标记绩优的客户经理', labelId: 2, revision: 2, userList: [{ labelId: 2, realName: '快乐朋友', userId: '78946', userName: 'kuailepengyou' }, { labelId: 2, realName: '快乐', userId: 3, userName: 'kuaile' }] },
        { labelName: '优质客经么', labelDesc: '用于标记优质客经么', labelId: 3, revision: 3, userList: [] }
      ]
    }
  }
})

// 添加标签
Mock.mock(`${baseURL}/v1/api/esale-user/label/add`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 删除标签
Mock.mock(`${baseURL}/v1/api/esale-user/label/delete/3`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 添加标签
Mock.mock(`${baseURL}/v1/api/esale-user/label/relate/user`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { realName: '快乐星球', userId: '78956' },
      { realName: '快乐朋友', userId: '78946' }
    ]
  }
})

// 获取单个用户详情
Mock.mock(`${baseURL}/v1/api/esale-user/user/queryById/78956`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      userName: 'kuailexingqiu',
      realName: '快乐星球',
      userId: '78956',
      gender: 'M',
      idNbr: '2134545454543545',
      organizationId: '1',
      origin: '广州市',
      organizationName: '某某分行',
      roleName: '某莫职务',
      userStatus: '1',
      userStatusName: '在线',
      imgBase64: require('../../../assets/image/penguins.jpg'),
      onlineStatus: '2',
      birthday: '1989-10-10',
      degree: '1',
      email: '122@qq.com',
      graduateSchool: '清华大学',
      labelIds: [{ labelId: 1, labelName: '风险客经' }],
      phone: '18824156562',
      graduateTime: '2014-07-01',
      profession: '画饼',
      remark: '备注',
      roleId: '1',
      wxAccount: '122@qq.com'
    }
  }
})

// 更新用户
Mock.mock(`${baseURL}/v1/api/esale-user/user/edit`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 添加标签
Mock.mock(`${baseURL}/v1/api/esale-user/user/relate/label`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: [
      { labelName: '风险客经', labelId: 1 },
      { labelName: '优质客经', labelId: 2 }
    ]
  }
})
